/*
*
* SPDX-License-Identifier: GPL-2.0
*
* Copyright (C) 2011-2018 ARM or its affiliates
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2.
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include "acamera_command_api.h"
#include "acamera_firmware_settings.h"
// created from 2016-10-19T16:42:58.865Z UTClinear.json

// CALIBRATION_LIGHT_SRC
static uint16_t _calibration_light_src[][2] = {
  { 248, 248 },
  { 385, 175 }
};

// CALIBRATION_RG_POS
static uint16_t _calibration_rg_pos[] = {151,166,181,197,212,227,243,256,273,288,304,319,334,350,384};

// CALIBRATION_BG_POS
static uint16_t _calibration_bg_pos[] = {178,198,217,237,256,276,295,315,334,354,373,393,412,432,465};

// CALIBRATION_MESH_RGBG_WEIGHT
static uint16_t _calibration_mesh_rgbg_weight[][15] = {
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 9, 22, 86 },
  { 0, 0, 0, 0, 0, 0, 0, 3, 15, 35, 64, 117, 192, 256, 256 },
  { 0, 0, 0, 0, 0, 0, 3, 27, 110, 256, 256, 256, 256, 169, 26 },
  { 0, 0, 0, 0, 0, 6, 35, 132, 256, 256, 186, 101, 38, 10, 0 },
  { 0, 0, 0, 1, 10, 69, 202, 256, 227, 96, 25, 3, 0, 0, 0 },
  { 0, 0, 0, 2, 26, 125, 256, 256, 146, 43, 8, 1, 0, 0, 0 },
  { 0, 0, 2, 16, 92, 242, 256, 181, 55, 8, 1, 0, 0, 0, 0 },
  { 0, 1, 12, 68, 212, 256, 210, 71, 12, 1, 0, 0, 0, 0, 0 },
  { 0, 7, 52, 173, 256, 234, 96, 18, 2, 0, 0, 0, 0, 0, 0 },
  { 2, 32, 151, 256, 256, 111, 26, 3, 0, 0, 0, 0, 0, 0, 0 },
  { 8, 79, 243, 256, 146, 33, 4, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 20, 156, 256, 199, 48, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 35, 215, 256, 107, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 62, 256, 212, 42, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 149, 256, 79, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};

// CALIBRATION_MESH_LS_WEIGHT
static uint16_t _calibration_mesh_ls_weight[][15] = {
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 3, 4, 25, 42, 53, 57, 53, 42, 25, 4, 3, 0, 0 },
  { 0, 0, 4, 131, 157, 179, 193, 198, 193, 179, 157, 131, 4, 0, 0 },
  { 0, 0, 25, 157, 188, 214, 232, 238, 232, 214, 188, 157, 25, 0, 0 },
  { 0, 0, 42, 179, 214, 243, 255, 256, 255, 243, 214, 179, 42, 0, 0 },
  { 0, 0, 53, 193, 232, 255, 256, 256, 256, 255, 232, 193, 53, 0, 0 },
  { 0, 0, 57, 198, 238, 256, 256, 256, 256, 256, 238, 198, 57, 0, 0 },
  { 0, 0, 53, 193, 232, 255, 256, 256, 256, 255, 232, 193, 53, 0, 0 },
  { 0, 0, 42, 179, 214, 243, 255, 256, 255, 243, 214, 179, 42, 0, 0 },
  { 0, 0, 25, 157, 188, 214, 232, 238, 232, 214, 188, 157, 25, 0, 0 },
  { 0, 0, 4, 131, 157, 179, 193, 198, 193, 179, 157, 131, 4, 0, 0 },
  { 0, 0, 3, 4, 25, 42, 53, 57, 53, 42, 25, 4, 3, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};

// CALIBRATION_MESH_COLOR_TEMPERATURE
static uint16_t _calibration_mesh_color_temperature[][15] = {
  { 197, 211, 224, 236, 249, 261, 261, 261, 266, 282, 297, 313, 328, 343, 348 },
  { 189, 189, 202, 214, 227, 240, 252, 261, 261, 272, 287, 302, 318, 333, 348 },
  { 187, 189, 189, 192, 205, 218, 230, 243, 256, 262, 277, 293, 308, 323, 348 },
  { 182, 184, 186, 188, 189, 195, 207, 220, 233, 246, 267, 282, 298, 313, 348 },
  { 176, 178, 180, 181, 183, 185, 187, 189, 201, 214, 227, 240, 284, 299, 336 },
  { 173, 175, 177, 179, 181, 182, 184, 186, 188, 202, 214, 227, 278, 293, 330 },
  { 169, 171, 172, 174, 176, 178, 180, 181, 183, 185, 187, 205, 218, 230, 320 },
  { 164, 166, 168, 169, 171, 173, 175, 177, 179, 180, 182, 184, 186, 208, 310 },
  { 159, 161, 163, 165, 167, 169, 170, 172, 174, 176, 178, 179, 181, 183, 301 },
  { 152, 156, 159, 160, 162, 164, 166, 167, 169, 171, 173, 175, 177, 178, 183 },
  { 139, 144, 147, 151, 155, 159, 161, 163, 165, 167, 168, 170, 172, 174, 178 },
  { 132, 133, 134, 138, 142, 146, 149, 153, 160, 162, 164, 166, 167, 169, 173 },
  { 127, 128, 129, 130, 131, 132, 133, 140, 144, 148, 152, 161, 163, 165, 169 },
  { 121, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 143, 146, 150, 164 },
  { 118, 118, 118, 118, 118, 118, 118, 119, 120, 121, 122, 123, 124, 125, 128 }
};

// RG, BG, MULT. final wb gain adjuster for a sky scene. devided by CALIBRATION_WB_STRENGTH_MULT in use
static uint16_t _calibration_wb_strength[] = {1000, 1000, 1000};

// lux threshold for sky
static uint16_t _calibration_sky_lux_th[] = {10000};

// 1D rg/bg readout from color_temp
static uint16_t _calibration_ct_rg_pos_calc[] = {174,189,202,256,287,351};

// 1D rg/bg readout from color_temp
static uint16_t _calibration_ct_bg_pos_calc[] = {441,385,354,256,218,189};

// CALIBRATION_COLOR_TEMP
static uint16_t _calibration_color_temp[] = {118,135,159,189,261,348};

// CALIBRATION_CT65POS
static uint16_t _calibration_ct65pos[] = {2};

// CALIBRATION_CT40POS
static uint16_t _calibration_ct40pos[] = {5};

// CALIBRATION_CT30POS
static uint16_t _calibration_ct30pos[] = {5};

// CALIBRATION_EVTOLUX_EV_LUT
static uint32_t _calibration_evtolux_ev_lut[] //evlog2
    = {398775, 444491, 477818, 528405, 620780, 744998, 821797, 1051295, 1308509, 1373840, 1436952, 1573912, 1656816, 1918045, 2075972, 2322504, 2494615};
// = {296692,327407,550106,809489,871881,946642,1100166,1159400,1435931,1608343,1874631,2040442};

// CALIBRATION_EVTOLUX_LUX_LUT
static uint32_t _calibration_evtolux_lux_lut[] = {20000, 18000, 16000, 14000, 12000, 10100, 8900, 5120, 2560, 2080, 1800, 1200, 1000, 500, 320, 160, 100};


// CALIBRATION_BLACK_LEVEL_R
static uint16_t _calibration_black_level_r[][2] = {
  { 0, 256 },
  { 32, 260 },
  { 64, 260 },
  { 96, 260 }
};

// CALIBRATION_BLACK_LEVEL_GR
static uint16_t _calibration_black_level_gr[][2] = {
  { 0, 256 },
  { 32, 260 },
  { 64, 260 },
  { 96, 260 }
};

// CALIBRATION_BLACK_LEVEL_GB
static uint16_t _calibration_black_level_gb[][2] = {
  { 0, 256 },
  { 32, 260 },
  { 64, 260 },
  { 96, 260 }
};

// CALIBRATION_BLACK_LEVEL_B
static uint16_t _calibration_black_level_b[][2] = {
  { 0, 256 },
  { 32, 260 },
  { 64, 260 },
  { 96, 260 }
};

// CALIBRATION_STATIC_WB
static uint16_t _calibration_static_wb[] = {462,256,256,545};

// RR RG RB GR GG GB BR BG BB
static uint16_t _calibration_mt_absolute_ls_a_ccm[]
 = {372,32845,32807,32876,398,32802,13,33002,477};

// RR RG RB GR GG GB BR BG BB
static uint16_t _calibration_mt_absolute_ls_d40_ccm[]
 = {383,32867,32796,32847,378,32811,11,32948,425};

// RR RG RB GR GG GB BR BG BB
static uint16_t _calibration_mt_absolute_ls_d50_ccm[]
 = {362,32838,32804,32827,415,32868,7,32941,422};

//80%
// CALIBRATION_SHADING_LS_A_R
static uint8_t _calibration_shading_ls_a_r[]
 = {203,193,185,178,173,168,164,159,155,152,149,149,148,147,147,146,146,147,148,149,150,152,154,157,159,163,166,171,175,182,189,197,190,181,174,168,163,158,154,150,147,144,142,140,138,136,135,135,135,135,136,138,139,141,144,146,150,153,157,161,166,171,177,185,179,171,165,159,154,150,146,142,139,138,137,132,128,127,126,125,125,126,127,128,130,132,135,138,141,145,149,153,157,162,168,175,171,163,157,152,147,142,138,134,130,129,126,122,119,117,116,116,116,116,117,119,121,123,126,129,133,137,141,146,150,155,161,167,163,156,150,145,140,135,130,125,121,118,114,112,110,108,107,106,106,107,108,109,111,114,117,121,125,129,134,138,143,148,154,160,157,149,143,137,132,127,122,117,113,109,105,103,100,99,98,97,97,97,98,100,102,105,108,112,116,121,126,131,136,141,147,154,151,143,137,131,125,119,114,109,104,101,97,95,92,91,90,89,89,90,90,92,94,97,100,103,108,113,118,123,129,135,141,148,146,137,131,124,118,112,107,102,97,94,90,88,86,84,83,83,83,83,84,85,87,90,93,96,100,105,111,117,123,129,135,143,141,132,125,118,112,106,100,95,91,88,85,82,81,79,78,78,78,78,79,80,82,84,87,90,94,99,104,110,116,123,130,138,136,127,120,113,106,100,94,90,86,83,80,78,76,75,74,74,74,74,75,76,77,79,82,85,89,93,98,104,111,117,124,133,131,122,115,107,101,95,90,85,82,79,76,74,73,72,71,71,71,71,71,72,74,76,78,81,84,88,93,99,106,113,120,129,128,118,111,103,97,91,86,82,79,76,74,72,70,69,69,68,68,69,69,70,71,73,75,78,81,85,90,95,101,108,116,125,125,115,107,100,94,88,84,80,76,74,72,70,69,68,67,67,67,67,67,68,69,71,73,75,78,82,87,92,98,105,113,122,122,113,105,98,92,86,82,78,75,72,70,69,67,66,66,65,65,65,66,67,68,69,71,74,77,80,85,90,96,103,110,119,121,111,103,96,90,85,80,77,74,71,69,68,67,66,65,65,64,65,65,66,67,69,70,73,75,79,83,88,94,101,108,117,120,110,102,95,89,84,80,76,73,71,69,67,66,65,64,64,64,64,65,66,67,68,70,72,75,78,82,87,93,100,107,116,120,110,103,95,89,84,80,76,73,71,69,67,66,65,64,64,64,64,65,66,67,68,70,72,75,78,82,87,93,100,108,116,121,111,104,96,90,85,80,77,74,71,69,68,67,66,65,65,65,65,65,66,67,69,70,73,76,79,83,88,94,101,108,117,123,113,105,98,92,86,82,78,75,72,70,69,67,67,66,66,65,66,66,67,68,70,72,74,77,80,85,90,96,103,110,119,125,116,108,100,94,88,84,80,77,74,72,70,69,68,67,67,67,67,68,68,70,71,73,76,79,82,87,92,98,105,113,122,129,119,111,104,97,91,86,82,79,76,74,72,71,70,69,69,69,69,69,70,72,73,75,78,81,85,90,95,101,108,116,125,133,123,116,108,101,95,90,86,82,79,77,75,73,72,72,71,71,71,72,73,74,76,78,81,85,89,93,99,105,112,120,129,138,128,121,113,107,100,95,90,86,83,80,78,77,76,75,74,74,75,75,76,78,80,82,85,89,93,98,104,111,118,125,134,143,134,127,120,113,106,101,96,92,88,85,83,81,80,79,78,78,79,79,81,82,84,87,90,94,99,104,110,116,123,130,139,149,140,133,126,120,113,108,102,98,94,91,89,87,85,84,84,84,84,85,86,88,90,93,97,101,106,111,117,123,129,136,144,155,146,140,133,127,121,115,110,106,102,98,95,93,92,91,90,90,90,91,93,95,97,100,104,108,113,118,124,130,136,142,150,162,154,147,141,135,129,124,119,114,110,107,104,101,100,99,98,98,98,99,101,103,106,109,113,117,121,126,132,137,143,149,157,171,163,155,149,143,138,133,128,124,120,116,113,111,109,108,107,107,108,109,110,112,115,118,122,126,130,135,140,145,151,157,164,183,173,165,158,152,146,141,137,133,129,126,123,121,119,118,117,117,118,118,120,122,125,128,131,135,139,143,148,153,159,166,173,200,188,177,169,162,156,150,146,142,139,135,133,131,129,128,127,127,128,128,130,132,134,137,140,144,147,152,157,162,169,178,187,224,209,194,183,175,167,161,157,152,149,145,143,141,139,138,137,137,138,139,140,142,144,147,150,153,157,162,168,175,184,197,209,255,236,216,202,191,182,175,170,165,161,158,155,153,152,151,150,150,150,151,152,154,156,158,162,165,170,175,182,191,203,221,243};

// CALIBRATION_SHADING_LS_A_G
static uint8_t _calibration_shading_ls_a_g[]
 = {169,161,155,149,144,140,137,133,130,128,125,125,124,124,124,123,123,124,124,125,126,128,129,131,134,136,139,143,147,152,158,165,158,152,146,141,137,133,130,127,124,122,120,119,117,117,116,116,116,116,117,117,119,120,122,124,126,129,132,135,139,144,149,155,150,144,139,134,130,127,124,121,118,118,118,113,111,110,109,109,109,109,110,111,112,114,116,118,120,123,126,129,133,137,141,147,143,137,132,128,125,121,118,115,112,112,110,106,105,103,103,102,102,103,103,104,106,108,110,112,114,117,120,124,127,131,135,140,137,131,127,123,119,116,112,109,106,104,101,99,98,97,96,95,95,96,96,98,99,101,103,106,109,112,115,118,122,126,130,135,131,126,122,118,114,110,107,103,100,97,95,93,91,90,89,89,89,89,90,91,92,94,97,99,103,106,110,113,117,120,125,130,127,122,117,113,109,105,101,97,94,91,89,87,85,84,83,83,83,83,84,85,86,88,91,94,97,100,104,108,112,116,120,125,123,118,113,109,104,100,96,92,89,86,84,82,80,79,78,78,78,78,79,80,81,83,86,88,91,95,99,103,107,112,116,121,120,114,109,104,100,95,91,88,84,82,79,78,76,75,75,74,74,74,75,76,77,79,81,84,87,90,94,99,103,108,112,118,117,110,105,100,95,91,87,83,80,78,76,74,73,72,72,71,71,71,72,73,74,75,77,80,83,86,90,94,99,104,109,114,113,107,102,97,92,87,83,80,77,75,73,72,71,70,69,69,69,69,69,70,71,73,74,77,79,83,86,91,95,100,105,111,111,104,99,94,89,85,81,78,75,73,71,70,69,68,67,67,67,67,68,68,69,70,72,74,77,80,83,88,92,97,102,109,109,102,96,91,87,82,79,76,73,71,70,68,67,67,66,66,66,66,66,67,68,69,71,72,75,78,81,85,90,95,100,106,107,100,95,90,85,81,77,74,72,70,69,67,66,66,65,65,65,65,65,66,67,68,69,71,73,76,80,84,88,93,98,105,106,99,94,88,84,80,76,74,71,69,68,67,66,65,65,64,64,64,65,65,66,67,69,70,73,75,78,82,87,92,97,103,105,99,93,88,83,79,76,73,71,69,68,66,66,65,64,64,64,64,65,65,66,67,68,70,72,75,78,82,86,91,96,103,105,99,93,88,83,79,76,73,71,69,68,67,66,65,64,64,64,64,65,65,66,67,68,70,72,75,78,82,86,91,96,103,106,100,94,89,84,80,77,74,71,70,68,67,66,65,65,65,65,65,65,66,67,68,69,71,73,75,79,82,87,92,97,104,108,101,95,90,85,81,78,75,72,70,69,68,67,66,66,65,65,65,66,66,67,68,70,72,74,77,80,84,88,93,99,105,110,103,97,92,87,83,79,76,74,72,70,69,68,67,67,66,66,66,67,67,68,70,71,73,75,78,81,85,90,95,100,107,112,105,100,94,89,85,81,78,76,73,72,70,69,68,68,68,68,68,68,69,70,71,73,75,77,80,84,88,92,97,103,109,115,108,103,98,93,88,84,81,78,76,74,72,71,70,70,70,70,70,70,71,72,73,75,77,80,83,87,91,95,100,106,112,119,112,107,101,97,92,88,84,81,79,77,75,74,73,72,72,72,72,73,74,75,76,78,80,83,86,90,95,99,104,109,115,122,116,111,106,101,96,92,88,85,83,80,79,77,76,76,75,75,75,76,77,78,80,82,84,87,91,95,99,104,108,113,119,126,120,115,111,106,101,97,93,90,87,85,83,81,80,79,79,79,79,80,81,82,84,86,89,92,96,99,104,108,113,117,123,131,125,120,116,111,107,103,99,96,93,90,88,86,85,84,84,84,84,85,86,87,89,92,94,97,101,105,109,113,117,122,127,136,130,125,121,117,113,109,105,102,99,96,94,93,91,90,90,90,90,91,92,93,95,98,101,104,107,110,114,118,122,127,132,144,137,132,127,123,119,115,112,109,106,103,101,100,98,97,97,97,97,98,99,100,102,105,107,110,113,116,120,124,128,133,138,154,146,140,134,129,125,122,118,115,113,111,108,107,106,105,104,104,104,105,106,108,109,111,114,117,119,123,126,130,135,140,146,168,159,150,143,137,132,128,125,122,120,117,115,114,113,112,111,111,112,112,113,115,116,118,120,123,126,129,133,137,143,150,158,189,176,164,155,148,142,137,133,130,127,125,123,121,120,119,119,119,119,120,121,122,123,125,128,130,134,137,142,148,156,167,176,220,199,183,171,161,154,148,143,139,136,134,132,130,129,128,128,128,128,129,129,131,132,134,136,139,143,147,153,161,172,187,205};

// CALIBRATION_SHADING_LS_A_B
static uint8_t _calibration_shading_ls_a_b[]
 = {172,164,157,150,146,141,138,133,130,127,125,124,123,123,122,122,122,122,123,123,124,125,127,129,131,134,137,141,145,150,156,161,160,153,147,142,137,133,130,127,124,122,120,118,117,115,114,114,114,114,115,115,116,118,119,121,124,126,129,133,137,141,146,150,151,145,139,134,130,127,123,120,118,117,117,112,110,109,108,107,107,108,108,109,110,111,113,115,117,120,123,126,130,133,138,143,144,138,133,129,125,121,118,115,112,111,109,106,104,103,102,101,101,101,102,103,104,106,108,110,112,115,118,121,125,128,132,136,138,132,128,124,120,116,113,110,107,104,101,99,97,96,95,95,95,95,95,97,98,100,102,104,107,110,113,116,120,123,127,131,133,127,123,118,115,111,107,104,101,98,95,93,91,90,89,88,88,88,89,90,91,93,96,98,101,104,108,111,115,118,122,126,128,122,118,113,109,105,101,98,95,92,89,87,85,84,83,82,82,83,83,84,86,87,90,92,95,99,102,106,110,114,117,121,124,118,114,109,105,100,96,93,89,86,84,82,80,79,78,78,78,78,78,79,81,82,85,87,90,94,98,101,106,110,113,118,121,115,110,105,100,96,92,88,85,82,80,78,76,75,74,74,74,74,74,75,77,78,80,83,86,89,93,97,101,106,110,114,118,111,106,101,96,91,87,84,81,78,76,75,73,72,71,71,71,71,71,72,73,75,76,79,82,85,89,93,98,102,106,111,115,108,102,97,92,88,84,81,78,75,74,72,71,70,69,69,69,69,69,70,71,72,73,76,78,82,85,90,94,99,103,108,112,105,99,94,89,85,81,78,76,73,72,70,69,68,67,67,67,67,67,68,69,70,71,73,76,79,82,87,91,96,101,106,110,103,97,92,87,83,79,76,74,72,70,69,68,67,66,66,66,66,66,67,67,68,70,72,74,77,80,84,89,94,98,104,109,101,95,90,85,81,78,75,73,71,69,68,67,66,65,65,65,65,65,66,67,68,69,71,73,75,79,83,87,92,97,102,107,100,94,89,84,80,77,74,72,70,68,67,66,65,65,64,64,64,65,65,66,67,68,70,72,74,78,81,86,91,95,101,106,99,94,88,84,80,76,74,71,69,68,67,66,65,65,64,64,64,64,65,66,67,68,69,71,74,77,81,85,90,95,100,106,99,94,88,84,80,76,74,71,70,68,67,66,65,65,64,64,64,64,65,66,67,68,69,71,74,77,81,85,90,95,100,107,100,94,89,84,80,77,74,72,70,69,67,66,66,65,65,65,65,65,65,66,67,69,70,72,75,78,82,86,91,96,101,109,102,96,90,86,82,78,75,73,71,69,68,67,66,66,66,65,65,66,66,67,68,69,71,73,76,79,83,87,92,97,102,111,104,98,92,87,83,79,76,74,72,70,69,68,67,67,66,66,66,67,67,68,69,70,72,74,77,80,84,89,94,98,104,113,106,100,95,90,85,81,78,76,74,72,71,69,69,68,68,68,68,68,68,69,70,72,74,76,79,82,86,91,96,101,106,116,109,103,98,93,88,84,81,78,76,74,73,71,71,70,70,69,70,70,70,71,73,74,76,79,82,85,89,94,99,104,109,119,113,107,102,97,92,88,84,81,79,77,75,74,73,72,72,72,72,72,73,74,75,77,79,82,85,89,93,98,103,107,112,123,117,111,106,101,97,92,88,85,83,80,79,77,76,76,75,75,75,76,76,77,79,81,83,86,89,93,97,102,107,111,116,127,121,116,111,106,102,97,93,90,87,85,83,81,80,79,79,79,79,79,80,82,83,85,88,91,94,98,102,106,111,115,119,131,125,121,116,111,107,103,99,96,93,90,88,86,85,84,84,84,84,84,85,87,88,91,93,96,99,103,107,111,115,119,124,137,131,126,121,117,113,109,105,102,99,96,94,93,91,90,90,89,90,90,91,93,94,97,99,102,105,109,112,116,120,124,129,145,138,132,127,123,119,115,112,109,106,103,101,99,98,97,97,96,97,97,98,100,101,104,106,109,112,115,118,122,126,130,135,156,148,140,134,129,125,122,118,115,113,110,108,107,105,104,104,104,104,104,105,107,108,110,112,115,118,121,124,128,132,137,142,170,160,151,144,137,133,129,125,122,119,117,115,113,112,111,111,111,111,111,112,113,115,117,119,121,124,127,131,135,141,147,153,192,177,165,156,148,142,137,133,129,126,124,122,120,119,118,118,118,118,118,119,120,121,123,126,128,131,135,139,145,153,162,171,222,200,183,171,161,153,147,142,138,134,131,129,128,126,126,125,126,126,126,126,127,129,131,133,136,139,144,150,158,168,181,197};

// CALIBRATION_SHADING_LS_TL84_R
static uint8_t _calibration_shading_ls_tl84_r[]
 = {234,221,209,200,193,187,182,176,171,167,163,162,161,161,160,160,159,160,161,163,165,167,170,173,178,183,188,195,202,212,223,235,216,205,195,187,181,175,170,165,161,158,154,152,150,148,147,146,146,147,148,150,152,155,158,161,165,171,175,182,189,196,206,217,203,192,184,177,170,165,160,155,151,150,150,143,139,137,136,136,136,136,138,139,141,144,147,151,155,160,165,171,177,184,192,203,190,182,174,167,161,155,150,145,141,139,136,131,128,126,125,124,124,125,126,128,130,133,136,141,145,150,155,161,167,174,182,190,180,171,164,158,152,146,141,135,131,126,122,119,117,115,113,113,113,113,114,116,119,122,126,130,135,140,146,152,158,165,172,180,171,163,156,149,143,136,131,125,120,116,112,109,106,104,103,102,102,103,104,106,108,111,115,120,125,130,137,143,149,156,163,172,165,156,148,141,134,128,122,116,111,106,102,99,97,95,94,93,93,94,95,97,99,102,106,110,115,121,128,134,141,148,155,165,159,149,141,134,127,120,113,107,103,98,94,92,89,88,86,86,86,86,87,89,91,94,97,102,107,112,119,126,133,141,149,158,152,143,135,127,119,112,106,100,95,91,88,85,83,82,80,80,80,80,81,82,85,87,90,94,99,105,111,118,126,133,141,152,146,136,128,120,112,105,99,94,89,85,82,80,78,77,76,75,75,75,76,78,79,81,84,88,93,98,104,111,118,126,135,145,141,131,122,114,106,100,94,89,85,81,78,76,74,73,72,72,72,72,73,74,75,77,80,83,87,92,98,105,112,121,130,140,137,127,118,109,102,95,90,85,81,78,75,73,72,70,70,69,69,69,70,71,72,74,77,80,84,88,94,100,108,116,125,136,134,123,114,106,98,92,86,82,78,75,73,71,70,68,68,67,67,67,68,69,70,72,74,77,81,85,90,97,104,112,121,132,131,120,111,103,96,89,84,80,76,74,71,70,68,67,66,66,66,66,66,67,69,70,72,75,79,83,88,94,101,109,118,129,129,118,109,101,94,88,83,79,75,72,70,68,67,66,65,65,65,65,65,66,68,69,71,74,77,81,86,92,99,107,116,126,128,117,108,100,93,87,82,78,75,72,70,68,67,65,65,64,64,64,65,66,67,69,71,73,77,80,85,91,98,106,115,125,128,117,108,100,93,87,82,78,75,72,70,68,67,66,65,64,64,64,65,66,67,69,71,73,77,81,85,91,98,106,115,125,129,118,109,101,94,88,83,79,75,73,70,69,67,66,65,65,65,65,66,67,68,69,72,74,77,81,86,92,99,107,116,127,131,120,111,103,96,90,84,80,76,74,71,69,68,67,66,66,66,66,67,67,69,70,73,75,79,83,88,94,101,109,118,128,134,123,114,106,98,92,86,82,78,75,73,71,69,68,68,67,67,67,68,69,70,72,74,77,81,85,90,96,103,112,120,131,138,127,118,110,102,95,90,85,81,78,75,73,72,70,70,69,69,70,70,71,73,75,77,80,84,88,94,100,107,115,125,135,143,132,123,115,107,100,94,89,85,81,78,76,75,73,73,72,72,72,73,74,76,78,80,84,88,92,98,105,112,120,129,140,148,138,129,120,113,106,99,94,90,86,83,80,78,77,76,76,76,76,77,78,80,82,85,88,93,98,104,110,118,126,135,146,154,144,135,127,119,112,106,100,95,91,88,85,83,82,81,80,80,80,81,83,85,87,90,94,99,104,110,117,125,133,141,152,160,151,143,135,127,120,113,108,103,98,95,92,89,88,86,86,86,86,87,89,91,94,97,101,106,112,118,125,132,140,148,158,168,158,150,143,135,129,122,117,111,107,103,100,97,95,94,93,93,94,95,97,99,102,106,110,115,120,127,133,140,147,156,166,176,167,159,152,145,138,132,127,121,117,113,109,107,105,103,103,102,103,104,106,108,111,115,120,125,130,136,142,149,156,164,175,185,176,168,161,154,148,142,137,132,127,123,120,117,115,114,113,113,114,115,116,119,122,126,130,135,140,146,152,158,165,173,183,195,186,178,170,164,158,152,147,142,138,134,131,129,127,125,124,125,125,126,128,130,133,137,141,145,150,156,161,168,175,183,194,208,197,189,181,174,168,162,157,153,149,146,142,140,138,137,136,136,137,138,139,142,145,148,152,156,161,166,172,179,187,196,207,228,216,203,194,186,180,174,169,165,161,157,155,152,150,149,148,148,149,150,152,154,156,159,163,167,173,178,185,192,202,215,229,255,238,221,210,201,195,188,183,178,175,172,169,167,165,164,163,164,164,166,167,168,171,174,177,182,187,193,201,209,220,237,255};

// CALIBRATION_SHADING_LS_TL84_G
static uint8_t _calibration_shading_ls_tl84_g[]
 = {206,194,184,176,169,164,159,154,149,146,143,143,141,141,141,141,141,141,142,143,145,147,149,152,156,160,165,171,177,186,195,206,190,180,172,165,159,154,149,145,142,139,137,135,133,132,131,131,131,131,132,134,135,137,140,143,146,150,155,160,166,173,181,190,177,168,161,155,150,145,141,138,134,134,134,128,125,124,123,122,123,123,124,125,127,129,132,135,138,142,146,151,156,162,169,178,166,159,152,147,142,138,134,130,127,125,123,119,117,115,114,114,114,114,115,117,118,121,123,127,130,134,138,143,148,154,160,167,157,150,145,140,135,130,126,122,118,115,112,110,108,106,105,104,104,105,106,107,110,112,115,118,122,126,131,135,140,145,151,158,150,144,138,133,128,123,119,114,110,107,104,101,99,97,96,96,96,96,97,99,101,104,107,110,114,119,124,128,133,138,144,151,144,138,132,127,121,116,112,107,103,99,96,94,92,90,89,89,88,89,90,91,93,96,99,103,107,112,117,122,127,132,138,145,140,133,127,121,115,110,105,100,96,93,89,87,85,84,83,82,82,83,84,85,87,89,92,96,100,105,110,115,121,127,132,140,135,128,121,115,109,104,99,94,90,87,84,82,80,79,78,77,77,78,78,80,81,83,86,90,94,98,103,109,115,121,127,134,131,123,116,110,104,98,93,89,85,82,79,77,76,74,74,73,73,73,74,75,77,79,81,84,88,93,98,103,109,116,122,130,127,119,112,105,99,94,89,84,81,78,76,74,72,71,71,70,70,70,71,72,73,75,77,80,84,88,93,99,105,111,118,126,124,115,108,102,96,90,85,81,78,75,73,71,70,69,68,68,68,68,69,70,71,72,75,77,81,85,89,95,101,107,114,123,121,113,105,99,93,87,83,79,76,73,71,69,68,67,67,66,66,67,67,68,69,71,73,75,78,82,86,92,98,104,111,120,119,110,103,96,90,85,81,77,74,72,70,68,67,66,65,65,65,65,66,67,68,69,71,73,76,80,84,89,95,102,109,117,117,109,101,95,89,84,79,76,73,71,69,67,66,65,65,64,64,64,65,66,67,68,70,72,75,78,83,88,93,100,107,115,116,108,101,94,88,83,79,75,73,70,68,67,66,65,64,64,64,64,65,65,67,68,70,72,75,78,82,87,93,99,106,114,116,108,101,94,88,83,79,76,73,70,69,67,66,65,65,64,64,64,65,66,67,68,70,72,75,78,82,87,93,99,106,115,117,109,102,95,89,84,80,76,73,71,69,68,67,66,65,65,65,65,65,66,67,69,70,73,75,79,83,88,94,100,107,115,119,111,103,97,91,86,81,77,74,72,70,69,67,67,66,66,65,66,66,67,68,70,71,74,77,80,84,89,95,102,109,117,121,113,106,99,93,88,83,79,76,73,71,70,69,68,67,67,67,67,67,68,69,71,73,75,78,82,86,92,97,104,111,119,124,116,109,102,96,91,86,82,78,76,74,72,71,70,69,69,69,69,69,70,71,73,75,78,81,85,89,95,101,107,114,122,128,120,113,106,100,95,90,85,82,79,76,75,73,72,71,71,71,71,72,73,74,76,78,81,84,88,93,99,105,111,118,126,132,124,118,111,105,99,94,90,86,83,80,78,76,75,75,74,74,74,75,76,78,80,82,85,89,93,98,103,109,116,122,130,137,129,123,116,110,105,99,95,91,87,85,82,81,79,79,78,78,78,79,80,82,84,87,90,94,98,103,109,115,121,127,135,142,134,128,122,116,111,106,101,97,93,90,88,86,84,84,83,83,83,84,86,87,90,92,96,100,104,109,115,120,126,132,140,148,141,135,129,123,118,113,108,104,100,97,95,92,91,90,89,89,90,91,92,94,96,99,103,107,111,116,121,127,133,139,146,155,148,141,136,131,125,121,116,112,108,105,102,100,99,98,97,97,97,98,100,102,104,107,111,115,119,124,129,134,139,146,153,163,155,149,143,138,133,128,124,120,117,114,111,109,107,106,106,106,106,107,108,110,113,116,119,123,127,131,136,141,147,153,161,171,164,157,151,146,141,136,132,129,125,122,120,118,116,115,115,115,115,116,117,119,122,124,127,131,135,139,144,149,156,162,170,183,174,167,160,154,149,145,141,137,134,131,129,127,126,125,124,124,125,125,127,129,131,133,136,140,143,148,153,159,166,174,183,200,190,180,172,165,159,155,150,147,144,141,138,137,135,134,134,134,134,135,136,138,140,143,146,149,154,158,164,171,179,190,201,223,208,195,186,178,172,166,162,158,155,152,150,148,147,146,146,146,146,147,148,150,152,154,158,161,166,171,177,185,195,210,226};

// CALIBRATION_SHADING_LS_TL84_B
static uint8_t _calibration_shading_ls_tl84_b[]
 = {202,191,181,173,166,160,155,150,146,143,139,139,138,138,138,137,137,138,139,139,141,143,145,148,152,156,161,166,173,181,190,200,185,176,168,161,155,150,146,142,139,136,133,132,130,129,128,128,128,128,129,130,132,133,136,138,142,146,150,155,161,168,175,183,172,164,157,151,146,142,138,134,131,131,131,125,122,121,120,119,120,120,121,122,123,126,128,131,133,137,141,146,151,157,164,171,162,155,149,143,139,134,131,127,124,123,121,116,114,113,112,111,112,112,113,114,116,118,120,123,126,130,134,138,144,149,155,161,153,147,141,136,132,127,124,120,116,113,110,108,106,104,103,103,103,103,104,106,108,110,113,116,119,123,127,132,136,141,146,153,147,140,135,129,125,121,116,112,109,105,102,100,98,96,96,95,95,95,96,98,99,102,105,108,112,116,120,125,130,134,139,145,141,134,129,124,119,114,110,105,101,98,95,93,91,89,88,88,88,88,89,90,92,94,97,101,105,109,114,119,124,128,133,139,136,130,124,118,113,108,103,99,95,92,89,86,85,83,82,82,82,82,83,84,86,88,91,94,98,103,108,113,118,123,128,134,132,125,119,113,107,102,97,93,89,86,83,81,79,78,77,77,77,77,78,79,80,83,85,88,92,97,101,107,112,118,123,129,128,120,114,108,102,97,92,88,84,81,79,77,75,74,73,73,73,73,74,75,76,78,80,83,87,91,96,101,107,113,118,125,124,116,110,104,98,93,88,84,80,78,76,74,72,71,70,70,70,70,71,72,73,74,77,79,83,87,92,97,102,108,114,121,121,113,106,100,94,89,85,81,78,75,73,71,70,69,68,68,68,68,69,69,71,72,74,77,80,83,88,93,99,105,111,118,118,110,103,97,91,86,82,78,76,73,71,70,68,67,67,66,66,67,67,68,69,70,72,74,77,81,85,90,96,102,108,115,116,108,101,95,89,84,80,77,74,72,70,68,67,66,66,65,65,65,66,67,68,69,71,73,76,79,83,88,93,99,106,113,115,107,100,93,88,83,79,76,73,71,69,68,67,66,65,64,64,65,65,66,67,68,70,72,74,78,82,86,92,98,104,111,114,106,99,93,87,82,78,75,72,70,69,67,66,65,65,64,64,64,65,65,67,68,69,71,74,77,81,86,91,97,103,110,114,106,99,93,87,83,79,75,73,71,69,68,66,66,65,64,64,65,65,66,67,68,70,72,74,77,81,86,91,97,103,110,115,107,100,94,88,83,79,76,73,71,69,68,67,66,65,65,65,65,66,66,67,69,70,72,75,78,82,87,92,98,104,111,116,108,102,95,90,85,80,77,74,72,70,69,68,67,66,66,66,66,66,67,68,69,71,73,76,79,83,88,93,99,105,112,119,111,104,97,92,87,82,79,76,73,71,70,69,68,67,67,67,67,68,68,69,71,73,75,78,81,85,90,95,102,108,114,121,114,107,100,95,89,85,81,78,76,73,72,71,70,69,69,69,69,69,70,71,73,75,77,80,84,88,93,98,104,111,118,125,117,111,104,98,93,89,84,81,78,76,74,73,72,71,71,71,71,72,73,74,75,77,80,83,87,91,97,102,108,114,121,129,122,115,109,103,98,93,88,85,82,79,78,76,75,74,74,74,74,75,76,77,79,81,84,87,91,96,101,107,113,119,126,133,126,120,114,108,103,98,93,90,86,84,82,80,79,78,78,78,78,78,80,81,83,85,88,92,96,101,106,112,117,123,130,138,131,125,119,114,109,104,99,95,92,89,87,85,84,83,82,82,83,83,85,86,88,91,94,98,102,107,112,117,122,128,135,144,137,131,125,120,115,110,106,102,98,96,93,91,90,89,88,88,89,89,91,92,95,98,101,105,109,113,118,123,128,134,140,151,144,138,132,127,122,118,114,109,106,103,101,99,97,96,96,96,96,97,98,100,102,105,108,112,116,120,125,130,135,140,147,159,151,145,139,134,129,125,121,118,114,111,109,107,105,104,104,104,104,105,106,108,110,113,116,120,123,127,132,136,142,148,155,168,160,153,147,142,137,133,129,125,123,120,117,115,114,113,113,112,113,113,115,116,119,121,124,127,131,135,139,145,150,157,164,180,171,163,156,150,145,141,137,133,131,128,126,124,123,122,121,121,121,122,123,125,127,130,132,135,139,144,149,154,161,168,177,197,186,175,167,161,155,150,146,142,139,137,134,133,131,131,130,130,130,131,132,134,136,138,142,145,149,154,159,166,174,184,195,219,204,191,181,173,167,162,157,153,150,147,145,143,142,141,140,140,141,142,143,144,146,149,152,156,160,166,172,180,189,202,217};

// CALIBRATION_SHADING_LS_D65_R
static uint8_t _calibration_shading_ls_d65_r[]
 = {220,206,194,185,178,172,167,162,157,154,150,149,148,148,147,147,147,147,148,150,151,153,155,158,161,165,170,176,182,191,202,215,201,190,180,173,166,161,156,152,149,145,142,140,139,137,136,136,136,136,137,139,140,142,145,148,151,155,159,164,170,177,187,196,186,177,169,162,156,152,147,143,140,139,139,133,129,128,127,126,127,127,128,129,131,133,136,139,142,146,150,154,160,166,173,182,174,166,159,153,148,143,139,134,131,130,128,123,120,119,118,117,117,118,119,120,122,125,127,130,134,138,142,147,152,158,164,171,165,158,151,146,140,135,131,127,123,119,116,113,111,110,108,108,108,108,109,111,113,116,119,122,126,130,135,140,144,150,156,163,158,151,144,138,133,128,123,119,114,111,107,105,102,101,100,99,99,100,101,102,104,107,110,114,118,123,128,132,138,143,149,156,151,144,138,132,126,121,116,111,106,103,99,97,95,93,92,91,91,92,93,94,96,99,102,106,110,115,120,125,131,136,142,150,146,138,132,126,119,114,108,103,99,95,92,90,88,86,85,85,85,85,86,87,89,92,95,98,103,108,113,119,124,130,137,144,140,133,126,120,113,107,102,97,93,89,87,84,82,81,80,80,79,80,81,82,84,86,89,92,96,101,106,112,118,125,131,139,136,128,121,114,108,102,96,92,88,84,82,80,78,77,76,75,75,76,76,78,79,81,84,87,91,95,101,106,113,119,126,134,132,124,116,109,103,97,92,87,84,81,78,76,75,74,73,72,72,73,73,74,76,78,80,83,86,91,96,102,108,115,122,130,128,120,112,105,99,93,88,84,81,78,75,74,72,71,70,70,70,70,71,72,73,75,77,80,83,87,92,97,104,111,118,127,125,116,109,102,96,90,85,81,78,75,73,72,70,69,68,68,68,68,69,70,71,73,75,77,80,84,89,94,101,107,115,123,123,114,107,100,94,88,83,80,76,74,72,70,69,68,67,67,66,67,67,68,70,71,73,75,78,82,87,92,98,105,112,121,122,113,105,98,92,87,82,79,75,73,71,69,68,67,66,65,65,65,66,67,69,70,72,74,77,81,85,90,96,103,110,119,121,112,104,98,91,86,82,78,75,72,71,69,68,66,65,64,64,65,66,67,68,70,72,74,77,80,84,89,95,102,110,118,121,112,104,97,91,86,82,78,75,73,70,69,68,66,65,64,64,65,66,67,68,70,72,74,77,80,84,89,95,102,110,118,121,113,105,98,92,87,82,78,75,73,71,69,68,67,66,65,65,66,67,68,69,70,72,74,77,81,85,90,96,103,110,119,123,114,107,100,93,88,83,80,76,74,72,70,69,68,67,67,67,67,68,68,70,71,73,75,78,82,86,92,98,104,112,121,125,116,109,102,96,90,85,81,78,75,73,72,70,69,69,68,68,69,69,70,71,73,75,77,80,84,89,94,100,107,114,123,128,120,112,105,99,93,88,84,81,78,75,74,72,71,70,70,70,70,71,72,73,75,77,80,83,87,91,97,103,110,117,126,132,123,116,109,103,97,92,87,84,81,78,76,75,74,73,73,72,73,73,74,76,77,80,83,86,90,95,101,107,114,121,129,136,128,121,114,107,101,96,92,88,84,82,80,78,77,76,76,76,76,77,78,79,81,84,87,90,95,100,106,112,118,125,133,141,133,126,119,113,107,102,97,93,89,86,84,82,81,80,80,80,80,81,82,83,86,88,92,96,100,105,111,117,124,130,138,146,138,132,126,119,114,108,103,99,95,92,90,88,86,85,85,85,85,86,87,89,91,94,98,102,107,112,117,123,129,136,144,152,145,138,132,126,120,115,110,106,102,99,96,94,93,92,91,91,92,92,94,96,98,101,105,109,114,119,124,129,135,142,150,159,151,145,139,133,128,123,118,114,110,107,104,102,100,99,99,99,99,100,102,104,106,109,113,117,121,126,131,136,142,148,156,167,159,152,146,141,136,131,126,123,119,116,113,111,109,108,107,107,108,109,110,112,115,118,121,125,129,133,138,144,150,156,164,176,168,161,154,149,144,139,135,131,128,125,122,120,119,117,117,117,117,118,120,122,124,126,130,133,137,142,146,152,158,165,173,188,178,170,163,157,152,147,143,139,136,133,131,129,128,127,126,126,126,127,129,131,133,135,138,142,146,150,155,161,168,176,185,204,193,182,174,168,162,157,152,149,145,143,140,138,137,136,135,135,136,137,138,140,142,145,148,151,155,160,166,172,180,190,201,225,210,197,188,180,174,168,164,160,156,154,151,149,148,147,146,146,147,148,149,150,153,155,159,163,167,172,178,185,195,207,222};

// CALIBRATION_SHADING_LS_D65_G
static uint8_t _calibration_shading_ls_d65_g[]
 = {201,190,179,171,165,159,154,150,145,142,139,139,137,137,137,136,136,137,138,139,140,142,144,146,149,153,157,162,169,176,187,198,184,175,167,160,154,149,145,141,138,135,133,131,129,128,127,127,127,127,128,129,131,132,134,137,140,143,147,152,157,164,172,180,171,163,156,150,145,140,136,133,130,129,129,124,121,120,119,118,118,119,120,121,122,124,127,129,132,135,139,143,148,153,160,167,160,153,147,142,137,133,129,125,122,121,119,115,113,111,110,110,110,110,111,113,114,117,119,122,125,128,132,136,141,146,151,158,152,146,140,135,130,126,122,118,115,111,109,106,104,103,102,101,102,102,103,104,106,109,111,115,118,122,126,130,134,139,144,150,146,139,134,129,124,120,115,111,107,104,101,98,96,95,94,93,94,94,95,96,98,101,104,107,111,115,119,124,128,133,138,144,140,133,128,123,118,113,108,104,100,97,94,91,89,88,87,86,86,87,88,89,91,93,96,100,104,108,113,117,122,127,132,138,135,128,123,117,112,107,102,97,94,90,87,85,83,82,81,80,80,81,82,83,85,87,90,93,97,102,106,111,117,122,127,133,130,124,118,112,106,101,96,92,88,85,82,80,78,77,76,76,76,76,77,78,80,82,84,88,91,96,101,106,111,117,122,129,127,119,113,107,101,96,91,87,83,80,78,76,74,73,72,72,72,72,73,74,75,77,80,83,86,91,95,101,106,112,118,125,123,115,109,103,97,92,87,83,79,77,74,73,71,70,69,69,69,69,70,71,72,74,76,79,82,86,91,96,102,108,114,121,119,112,105,99,93,88,84,80,77,74,72,70,69,68,67,67,67,67,68,69,70,71,73,76,79,83,87,92,98,104,111,118,117,109,102,96,90,85,81,77,74,72,70,68,67,66,66,65,65,66,66,67,68,69,71,74,77,80,84,89,95,101,108,115,115,107,100,94,88,83,79,76,73,71,69,67,66,65,65,64,64,64,65,66,67,68,70,72,75,78,82,87,93,99,105,113,114,106,99,93,87,82,78,75,72,70,68,66,65,64,64,64,64,64,64,65,66,67,69,71,74,77,81,86,91,97,104,111,113,105,98,92,86,82,78,74,71,69,67,66,65,64,64,64,64,64,64,65,66,67,69,71,73,77,80,85,90,96,103,111,113,105,98,92,86,82,78,74,71,69,67,66,65,64,64,64,64,64,64,65,66,67,69,71,73,76,80,85,90,96,103,110,113,106,99,93,87,82,78,75,72,70,68,67,65,65,64,64,64,64,64,65,66,67,69,71,74,77,81,86,91,97,104,111,115,107,101,94,89,84,79,76,73,71,69,67,66,66,65,65,65,65,65,66,67,68,70,72,75,78,82,87,93,99,105,113,117,109,103,96,91,86,81,78,75,72,70,69,68,67,66,66,66,66,66,67,68,70,72,74,77,80,84,89,95,101,107,115,120,112,106,99,94,88,84,80,77,74,72,71,69,68,68,68,67,68,68,69,70,72,74,76,79,83,87,92,98,104,110,118,123,116,109,103,97,92,87,83,80,77,75,73,72,71,70,70,70,70,70,71,73,74,76,79,82,86,91,96,101,107,114,121,127,120,114,107,102,96,91,87,84,81,78,76,75,74,73,73,73,73,73,74,76,78,80,83,86,90,95,100,106,112,117,124,131,124,118,113,107,102,97,92,88,85,83,80,79,78,77,76,76,77,77,78,80,82,85,88,91,95,100,105,111,116,122,129,136,129,124,118,113,107,102,98,94,91,88,86,84,83,82,81,81,81,82,83,85,87,90,93,97,101,106,111,116,121,127,133,141,135,129,124,119,114,109,105,101,97,94,92,90,88,88,87,87,87,88,89,91,94,96,100,103,107,112,117,122,127,132,138,147,141,135,130,125,120,116,112,108,104,101,99,97,95,94,94,94,94,95,96,98,101,103,107,110,114,118,123,128,133,138,144,154,148,142,137,132,127,123,119,115,112,109,107,105,104,102,102,102,102,103,105,106,109,111,114,118,121,125,129,134,139,145,152,163,156,150,144,139,134,130,127,123,120,118,115,114,112,111,111,111,111,112,113,115,117,119,122,125,129,133,137,142,147,154,161,174,166,159,153,147,142,138,135,131,128,126,124,122,121,120,119,119,119,120,121,123,125,127,130,133,136,141,145,150,156,164,172,189,179,170,163,156,151,147,143,140,137,134,132,130,129,128,128,128,128,129,130,131,133,136,138,141,145,150,154,160,168,177,186,207,195,184,175,168,162,157,153,150,147,144,142,140,139,138,138,138,138,139,140,141,143,146,148,152,156,160,166,172,181,192,205};

// CALIBRATION_SHADING_LS_D65_B
static uint8_t _calibration_shading_ls_d65_b[]
 = {206,194,184,175,168,162,157,152,147,143,140,140,138,139,138,138,138,138,138,139,141,142,145,147,150,154,158,164,170,178,187,197,187,178,170,162,156,151,146,142,139,136,134,132,130,129,128,127,128,128,129,130,131,133,135,137,140,144,148,153,158,165,172,179,173,165,158,151,146,142,138,134,131,130,130,125,122,120,119,119,119,119,120,121,123,125,127,129,132,135,139,143,148,154,160,166,163,156,149,144,139,134,130,127,124,123,120,116,114,113,111,111,111,112,112,114,115,118,120,122,125,129,132,137,141,146,151,157,155,148,142,137,132,128,124,120,117,113,111,108,106,105,104,103,103,104,105,106,108,110,113,116,119,123,127,131,135,139,145,150,148,141,136,130,126,121,117,113,109,106,103,100,98,97,96,95,95,96,97,98,100,102,105,109,112,116,120,124,129,133,138,143,142,135,129,124,119,114,110,106,102,99,95,93,91,90,89,88,88,89,89,91,93,95,98,101,105,109,114,118,123,128,132,137,136,130,124,119,113,108,104,99,95,92,89,87,85,84,83,82,82,83,83,85,86,89,91,95,98,103,108,112,117,122,127,132,132,125,119,114,108,103,98,94,90,87,84,82,80,79,78,78,78,78,79,80,81,84,86,89,93,97,102,107,112,117,122,128,129,121,115,109,103,98,93,89,85,82,80,78,76,75,75,74,74,74,75,76,77,79,82,85,88,92,97,102,107,113,118,124,125,117,111,104,99,93,89,85,82,79,77,75,73,72,72,71,71,71,72,73,74,76,78,81,84,88,92,97,103,109,114,121,121,113,107,101,95,90,86,82,79,76,74,72,71,70,69,69,69,69,70,71,72,73,75,77,81,84,89,94,99,105,111,118,119,111,104,98,92,87,83,80,77,74,72,71,69,69,68,67,67,68,68,69,70,71,73,75,78,82,86,91,96,102,108,114,117,109,102,96,90,85,81,78,75,73,71,70,68,67,67,66,66,67,67,68,69,70,72,74,77,80,84,89,94,100,106,112,116,107,101,94,89,84,80,77,74,72,70,69,68,67,66,65,65,65,66,67,68,69,71,73,76,79,83,87,92,98,104,111,114,107,100,94,88,83,80,76,74,72,70,69,67,66,65,64,64,64,66,67,68,69,71,73,75,78,82,86,92,97,103,110,114,106,100,94,88,83,79,76,74,72,70,69,67,67,65,64,64,65,66,67,68,69,71,72,75,78,82,86,91,97,103,110,115,107,101,94,89,84,80,77,74,72,70,69,68,67,66,66,65,66,67,67,68,70,71,73,75,78,82,87,92,98,104,111,117,109,102,96,90,86,82,78,75,73,71,70,69,68,68,67,67,67,68,68,69,71,72,74,77,80,84,88,94,100,105,112,119,111,104,98,93,88,83,80,77,75,73,71,70,69,69,68,68,68,69,69,70,72,74,76,78,82,86,90,96,102,107,114,122,114,107,101,95,90,86,82,79,77,75,73,72,71,70,70,70,70,70,71,72,74,75,78,81,84,88,93,99,104,110,117,125,117,111,105,99,94,89,85,82,79,77,75,74,73,72,72,72,72,73,73,74,76,78,80,84,87,91,96,102,108,113,120,129,121,115,109,103,98,93,89,85,83,80,79,77,76,75,75,75,75,75,76,78,79,81,84,87,91,96,101,106,112,117,123,133,126,120,114,109,103,98,94,90,87,85,83,81,80,79,79,79,79,79,80,82,84,86,89,92,96,101,106,111,117,122,128,138,131,125,120,114,109,104,100,96,93,90,88,86,85,84,83,83,83,84,85,87,89,91,94,98,102,107,111,116,121,126,132,143,137,131,125,120,115,110,106,102,99,96,94,92,90,89,89,89,89,90,91,93,95,97,101,104,108,112,117,121,126,131,137,150,143,137,131,126,122,117,113,109,106,103,101,99,97,96,96,95,96,97,98,99,102,104,108,111,115,119,123,127,132,137,143,157,150,144,138,133,129,125,121,117,114,111,109,107,105,104,104,104,104,105,106,108,110,112,115,118,122,126,130,134,139,145,151,167,159,152,146,141,136,132,128,125,122,119,117,115,114,113,112,112,112,113,114,116,118,120,123,126,129,133,137,142,148,153,160,179,169,161,155,149,144,140,136,133,130,127,125,123,122,121,121,120,121,121,122,124,126,128,131,133,137,141,146,151,157,164,172,194,183,173,165,158,153,148,144,141,137,135,133,131,130,129,128,128,129,129,130,132,133,136,138,142,145,150,155,161,168,176,186,213,199,186,177,169,163,158,154,150,146,144,141,140,139,138,137,137,138,138,139,141,142,145,148,151,155,160,166,173,182,192,203};

// R G B
static uint16_t _calibration_awb_warming_ls_a[] = {256, 256, 256};

// R G B
static uint16_t _calibration_awb_warming_ls_d75[] = {256, 256, 256};

// R G B
static uint16_t _calibration_awb_warming_ls_d50[] = {256, 256, 256};

// CALIBRATION_NOISE_PROFILE
static uint8_t _calibration_noise_profile[] = {0,0,7,22,28,32,35,38,39,41,42,44,45,46,47,47,49,49,50,51,51,52,53,53,54,54,55,55,56,56,56,57,57,58,58,58,59,59,59,60,60,60,60,61,61,61,62,62,62,62,63,63,63,63,63,64,64,64,64,64,65,65,65,65,65,66,66,66,66,66,66,67,67,67,67,67,67,68,68,68,68,68,68,68,69,69,69,69,69,69,69,70,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,73};
//  = {0,0,0,0,0,0,0,2,43,57,61,65,67,74,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85};

// CALIBRATION_DEMOSAIC
static uint8_t _calibration_demosaic[] = {7,23,29,33,36,38,40,42,43,44,46,47,48,49,50,50,51,52,52,53,53,54,55,55,55,56,56,57,57,58,58,58,59,59,59,60,60,60,61,61,61,62,62,62,62,63,63,63,63,64,64,64,64,64,65,65,65,65,65,66,66,66,66,66,67,67,67,67,67,67,68,68,68,68,68,68,69,69,69,69,69,69,69,70,70,70,70,70,70,70,71,71,71,71,71,71,71,71,71,72,72,72,72,72,72,72,72,72,73,73,73,73,73,73,73,73,73,74,74,74,74,74,74,74,74,74,74,74};
// = {2,43,57,61,65,67,74,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85};

// 8-bit normalised noise profile for WDR stitching
static uint8_t _calibration_wdr_np_lut[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

// CALIBRATION_GAMMA
static uint16_t _calibration_gamma[] =
    {0,144,289,426,541,641,730,812,887,957,1024,1086,1146,1203,1257,1310,1360,1409,1456,1502,1547,1590,1632,1673,1714,1753,1791,1829,1866,1902,1938,1972,2007,2040,2073,2106,2138,2169,2200,2231,2261,2291,2321,2350,2378,2406,2434,2462,2489,2516,2543,2569,2596,2621,2647,2672,2697,2722,2747,2771,2795,2819,2843,2866,2889,2913,2935,2958,2981,3003,3025,3047,3069,3090,3112,3133,3154,3175,3196,3217,3237,3258,3278,3298,3318,3338,3358,3378,3397,3417,3436,3455,3474,3493,3512,3530,3549,3567,3586,3604,3622,3640,3658,3676,3694,3712,3729,3747,3764,3782,3799,3816,3833,3850,3867,3884,3900,3917,3934,3950,3967,3983,3999,4016,4032,4048,4064,4080,4095};
/*{0, 120, 246, 370, 478, 574, 661, 743, 819, 891, 962, 1031, 1100, 1167, 1232, 1298, 1360, 1421, 1481, 1539, 1596, 1650, 1703, 1755, 1805, 1853, 1899, 1944, 1988, 2029, 2070, 2107, 2145, 2179, 2212, 2245, 2276, 2305, 2334, 2363, 2390, 2416, 2442, 2467, 2491, 2515, 2538, 2562, 2584, 2606, 2628, 2649, 2671, 2691, 2712, 2732, 2752, 2772, 2793, 2812, 2832, 2851, 2871, 2890, 2910, 2930, 2949, 2968, 2988, 3008, 3027, 3047, 3067, 3086, 3106, 3126, 3146, 3165, 3185, 3205, 3224, 3244, 3263, 3282, 3301, 3320, 3340, 3359, 3378, 3397, 3416, 3434, 3453, 3472, 3491, 3509, 3527, 3545, 3564, 3583, 3601, 3619, 3637, 3655, 3674, 3692, 3709, 3728, 3745, 3764, 3782, 3799, 3817, 3834, 3852, 3870, 3887, 3905, 3923, 3939, 3957, 3974, 3991, 4009, 4026, 4044, 4061, 4078, 4095};*/

// static uint16_t _calibration_gamma[]
//  //= {0,60,122,186,250,314,375,431,484,533,580,625,668,710,750,789,827,864,900,936,972,1006,1041,1075,1110,1143,1176,1208,1240,1273,1304,1334,1365,1395,1425,1454,1483,1511,1539,1568,1595,1622,1648,1674,1700,1726,1750,1776,1800,1823,1847,1870,1893,1915,1938,1960,1981,2002,2023,2044,2065,2084,2103,2123,2142,2160,2178,2197,2214,2232,2249,2266,2283,2300,2316,2332,2348,2365,2380,2396,2412,2427,2443,2458,2473,2488,2503,2517,2532,2546,2560,2575,2588,2602,2616,2630,2643,2657,2670,2684,2697,2710,2723,2737,2750,2761,2774,2787,2800,2812,2824,2837,2848,2861,2873,2884,2897,2908,2920,2932,2943,2955,2966,2978,2989,2999,3011,3022,3033,3044,3055,3066,3076,3088,3098,3108,3120,3130,3140,3150,3161,3171,3181,3191,3202,3212,3221,3231,3242,3252,3261,3271,3280,3290,3300,3310,3319,3329,3338,3347,3356,3367,3376,3385,3394,3403,3412,3421,3430,3439,3448,3457,3466,3475,3484,3493,3502,3510,3519,3527,3536,3544,3553,3561,3570,3578,3587,3595,3604,3612,3619,3628,3636,3644,3652,3661,3668,3676,3684,3692,3700,3707,3715,3723,3731,3738,3746,3754,3762,3769,3777,3784,3791,3799,3807,3814,3821,3829,3836,3843,3851,3857,3865,3872,3879,3887,3894,3900,3908,3914,3922,3929,3935,3943,3949,3956,3963,3970,3977,3983,3991,3997,4004,4010,4017,4023,4031,4037,4044,4050,4057,4063,4070,4076,4083,4089,4095};
//  = {0, 44, 90, 140, 193, 248, 302, 355, 407, 458, 509, 559, 607, 655, 702, 748, 793, 837, 879, 922, 963, 1003, 1042, 1081, 1119, 1156, 1192, 1226, 1261, 1295, 1327, 1359, 1390, 1421, 1450, 1479, 1507, 1534, 1561, 1588, 1613, 1638, 1662, 1685, 1708, 1731, 1753, 1775, 1797, 1818, 1839, 1860, 1880, 1900, 1921, 1941, 1960, 1979, 1998, 2017, 2036, 2054, 2072, 2091, 2109, 2125, 2143, 2161, 2177, 2195, 2211, 2228, 2244, 2260, 2276, 2292, 2307, 2323, 2338, 2353, 2368, 2384, 2399, 2413, 2428, 2442, 2457, 2471, 2485, 2498, 2512, 2527, 2539, 2553, 2566, 2580, 2592, 2606, 2618, 2632, 2644, 2656, 2668, 2681, 2694, 2705, 2717, 2728, 2740, 2752, 2763, 2775, 2785, 2797, 2808, 2818, 2830, 2840, 2851, 2861, 2872, 2882, 2893, 2903, 2913, 2923, 2933, 2943, 2953, 2963, 2973, 2983, 2992, 3002, 3012, 3021, 3031, 3041, 3050, 3059, 3068, 3078, 3087, 3096, 3106, 3115, 3124, 3133, 3142, 3152, 3160, 3169, 3178, 3187, 3196, 3205, 3214, 3223, 3232, 3240, 3249, 3258, 3267, 3276, 3284, 3293, 3302, 3310, 3319, 3328, 3337, 3346, 3354, 3363, 3372, 3380, 3389, 3398, 3407, 3415, 3424, 3432, 3442, 3450, 3459, 3467, 3476, 3485, 3494, 3502, 3511, 3520, 3529, 3537, 3546, 3555, 3564, 3573, 3581, 3590, 3599, 3608, 3617, 3626, 3634, 3643, 3652, 3661, 3670, 3679, 3688, 3697, 3706, 3715, 3724, 3733, 3741, 3751, 3760, 3768, 3778, 3786, 3795, 3804, 3813, 3823, 3831, 3839, 3849, 3857, 3867, 3875, 3884, 3894, 3902, 3911, 3920, 3929, 3937, 3946, 3956, 3964, 3973, 3982, 3990, 3999, 4009, 4017, 4026, 4035, 4044, 4052, 4061, 4070, 4079, 4087, 4095, };

// // CALIBRATION_IRIDIX_ASYMMETRY
// static uint16_t _calibration_iridix_asymmetry[]
// // = {0,7517,13842,19240,23899,27962,31536,34704,37532,40072,42366,44448,46345,48082,49678,51149,52510,53772,54946,56041,57064,58023,58923,59769,60567,61319,62031,62705,63343,63950,64527,65076,65535};
// ={0, 61184, 116961, 168002, 214899, 258115, 298084, 335172, 369653, 401797, 431862, 460022, 486454, 511335, 534791, 556919, 577880, 597720, 616568, 634473, 651529, 667785, 683305, 698153, 712346, 725978, 739050, 751610, 763706, 775355, 786587, 797451, 807931, 818091, 827947, 837499, 846780, 855820, 864604, 873180, 881532, 889708, 897708, 905532, 913213, 920733, 928141, 935421, 942589, 949645, 956621, 963501, 970317, 977053, 983742, 990366, 996942, 1003470, 1009982, 1016446, 1022894, 1029326, 1035742, 1042158, 1048575, };

// CALIBRATION_IRIDIX_ASYMMETRY
static uint32_t _calibration_iridix_asymmetry[] = {0,62836,120267,172961,221481,266305,307839,346432,382386,415964,447392,476871,504577,530666,555274,578524,600526,621378,641167,659973,677867,694914,711172,726696,741534,755730,769325,782356,794859,806864,818400,829495,840173,850457,860369,869929,879155,888064,896672,904994,913045,920837,928383,935693,942780,949653,956321,962794,969080,975187,981123,986894,992508,997970,1003288,1008466,1013509,1018424,1023215,1027887,1032443,1036889,1041228,1045464,1048575};

static uint32_t _calibration_ca_filter_mem[] = {0x00008000, 0x000380fd, 0x00077efb, 0xff0b7df9, 0xff0f7bf7, 0xfe137af5, 0xfd1877f4, 0xfc1d74f3, 0xfb2271f2, 0xfa276df2, 0xfa2c68f2, 0xf93164f2, 0xf83660f2, 0xf73c5bf2, 0xf64156f3, 0xf54751f3, 0xf44c4cf4, 0xf35147f5, 0xf35641f6, 0xf25b3cf7, 0xf26036f8, 0xf26431f9, 0xf2682cfa, 0xf26d27fa, 0xf27122fb, 0xf3741dfc, 0xf47718fd, 0xf57a13fe, 0xf77b0fff, 0xf97d0bff, 0xfb7e0700, 0xfd800300};

// calibration_awb_scene_presets in the following order AWB_DAY_LIGHT AWB_CLOUDY AWB_INCANDESCENT AWB_FLOURESCENT AWB_TWILIGHT AWB_SHADE AWB_WARM_FLOURESCENT
static uint16_t _calibration_awb_scene_presets[7][2] = {
  { 256, 256 },
  { 347, 170 },
  { 187, 347 },
  { 228, 301 },
  { 228, 301 },
  { 377, 149 },
  { 187, 347 }
};

// CALIBRATION_CA_CORRECTION: MIN_CORRECTION, MESH_WIDTH, MESH_HEIGHT
static uint16_t _calibration_ca_correction[] = {1, 64, 64};

static uint16_t _calibration_ca_correction_mem[][10] = {
    {2, 0, 0, 65535, 65532, 0, 2, 11, 65535, 65524},
    {65531, 65534, 65535, 65532, 8, 2, 7, 65532, 3, 65532},
    {19, 6, 7, 65533, 65504, 65525, 0, 74, 2, 65413},
    {3, 17, 2, 14, 65525, 65517, 65515, 10, 42, 65444}};

static uint32_t _calibration_lut3d_mem[] = {0};

static uint32_t _calibration_decompander0_mem[] = {0, 32768, 65536, 98304, 131072, 163840, 196608, 229376, 262144, 294912, 327680, 360448, 393216, 425984, 458752, 491520, 524288, 557055, 589823, 622591, 655359, 688127, 720895, 753663, 786431, 819199, 851967, 884735, 917503, 950271, 983039, 1015807, 1048575};
static uint32_t _calibration_decompander1_mem[] = {0, 4096, 8192, 12288, 16384, 20480, 24576, 28672, 32768, 36864, 40960, 45056, 49152, 53248, 57344, 61440, 65536, 69632, 73728, 77824, 81920, 86016, 90112, 94208, 98304, 102400, 106496, 110592, 114688, 118784, 122880, 126976, 131072, 135168, 139264, 143360, 147456, 151552, 155648, 159744, 163840, 167936, 172032, 176128, 180224, 184320, 188416, 192512, 196608, 200704, 204800, 208896, 212992, 217088, 221184, 225280, 229376, 233472, 237568, 241664, 245760, 249856, 253952, 258048, 262144, 266240, 270336, 274432, 278528, 282624, 286720, 290816, 294912, 299008, 303104, 307200, 311296, 315392, 319488, 323584, 327680, 331776, 335872, 339968, 344064, 348160, 352256, 356352, 360448, 364544, 368640, 372736, 376832, 380928, 385024, 389120, 393216, 397312, 401408, 405504, 409600, 413696, 417792, 421888, 425984, 430080, 434176, 438272, 442368, 446464, 450560, 454656, 458752, 462848, 466944, 471040, 475136, 479232, 483328, 487424, 491520, 495616, 499712, 503808, 507904, 512000, 516096, 520192, 524288, 528383, 532479, 536575, 540671, 544767, 548863, 552959, 557055, 561151, 565247, 569343, 573439, 577535, 581631, 585727, 589823, 593919, 598015, 602111, 606207, 610303, 614399, 618495, 622591, 626687, 630783, 634879, 638975, 643071, 647167, 651263, 655359, 659455, 663551, 667647, 671743, 675839, 679935, 684031, 688127, 692223, 696319, 700415, 704511, 708607, 712703, 716799, 720895, 724991, 729087, 733183, 737279, 741375, 745471, 749567, 753663, 757759, 761855, 765951, 770047, 774143, 778239, 782335, 786431, 790527, 794623, 798719, 802815, 806911, 811007, 815103, 819199, 823295, 827391, 831487, 835583, 839679, 843775, 847871, 851967, 856063, 860159, 864255, 868351, 872447, 876543, 880639, 884735, 888831, 892927, 897023, 901119, 905215, 909311, 913407, 917503, 921599, 925695, 929791, 933887, 937983, 942079, 946175, 950271, 954367, 958463, 962559, 966655, 970751, 974847, 978943, 983039, 987135, 991231, 995327, 999423, 1003519, 1007615, 1011711, 1015807, 1019903, 1023999, 1028095, 1032191, 1036287, 1040383, 1044479, 1048575};

// CALIBRATION_SHADING_RADIAL_R
static uint16_t _calibration_shading_radial_r[] = {4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096};

// CALIBRATION_SHADING_RADIAL_G
static uint16_t _calibration_shading_radial_g[] = {4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096};

// CALIBRATION_SHADING_RADIAL_B
static uint16_t _calibration_shading_radial_b[] = {4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096,4096};

static LookupTable calibration_shading_radial_r = {.ptr = _calibration_shading_radial_r, .rows = 1, .cols = sizeof( _calibration_shading_radial_r ) / sizeof( _calibration_shading_radial_r[0] ), .width = sizeof( _calibration_shading_radial_r[0] )};
static LookupTable calibration_shading_radial_g = {.ptr = _calibration_shading_radial_g, .rows = 1, .cols = sizeof( _calibration_shading_radial_g ) / sizeof( _calibration_shading_radial_g[0] ), .width = sizeof( _calibration_shading_radial_g[0] )};
static LookupTable calibration_shading_radial_b = {.ptr = _calibration_shading_radial_b, .rows = 1, .cols = sizeof( _calibration_shading_radial_b ) / sizeof( _calibration_shading_radial_b[0] ), .width = sizeof( _calibration_shading_radial_b[0] )};
static LookupTable calibration_decompander0_mem = {.ptr = _calibration_decompander0_mem, .rows = 1, .cols = sizeof( _calibration_decompander0_mem ) / sizeof( _calibration_decompander0_mem[0] ), .width = sizeof( _calibration_decompander0_mem[0] )};
static LookupTable calibration_decompander1_mem = {.ptr = _calibration_decompander1_mem, .rows = 1, .cols = sizeof( _calibration_decompander1_mem ) / sizeof( _calibration_decompander1_mem[0] ), .width = sizeof( _calibration_decompander1_mem[0] )};

static LookupTable calibration_awb_scene_presets = {.ptr = _calibration_awb_scene_presets, .cols = 2, .rows = sizeof( _calibration_awb_scene_presets ) / sizeof( _calibration_awb_scene_presets[0] ), .width = sizeof( _calibration_awb_scene_presets[0][0] )};
static LookupTable calibration_light_src = {.ptr = _calibration_light_src, .cols = 2, .rows = sizeof( _calibration_light_src ) / sizeof( _calibration_light_src[0] ), .width = sizeof( _calibration_light_src[0][0] )};
static LookupTable calibration_rg_pos = {.ptr = _calibration_rg_pos, .rows = 1, .cols = sizeof( _calibration_rg_pos ) / sizeof( _calibration_rg_pos[0] ), .width = sizeof( _calibration_rg_pos[0] )};
static LookupTable calibration_bg_pos = {.ptr = _calibration_bg_pos, .rows = 1, .cols = sizeof( _calibration_bg_pos ) / sizeof( _calibration_bg_pos[0] ), .width = sizeof( _calibration_bg_pos[0] )};
static LookupTable calibration_mesh_rgbg_weight = {.ptr = _calibration_mesh_rgbg_weight, .cols = 15, .rows = sizeof( _calibration_mesh_rgbg_weight ) / sizeof( _calibration_mesh_rgbg_weight[0] ), .width = sizeof( _calibration_mesh_rgbg_weight[0][0] )};
static LookupTable calibration_mesh_ls_weight = {.ptr = _calibration_mesh_ls_weight, .cols = 15, .rows = sizeof( _calibration_mesh_ls_weight ) / sizeof( _calibration_mesh_ls_weight[0] ), .width = sizeof( _calibration_mesh_ls_weight[0][0] )};
static LookupTable calibration_mesh_color_temperature = {.ptr = _calibration_mesh_color_temperature, .cols = 15, .rows = sizeof( _calibration_mesh_color_temperature ) / sizeof( _calibration_mesh_color_temperature[0] ), .width = sizeof( _calibration_mesh_color_temperature[0][0] )};
static LookupTable calibration_wb_strength = {.ptr = _calibration_wb_strength, .rows = 1, .cols = sizeof( _calibration_wb_strength ) / sizeof( _calibration_wb_strength[0] ), .width = sizeof( _calibration_wb_strength[0] )};
static LookupTable calibration_sky_lux_th = {.ptr = _calibration_sky_lux_th, .rows = 1, .cols = sizeof( _calibration_sky_lux_th ) / sizeof( _calibration_sky_lux_th[0] ), .width = sizeof( _calibration_sky_lux_th[0] )};
static LookupTable calibration_ct_rg_pos_calc = {.ptr = _calibration_ct_rg_pos_calc, .rows = 1, .cols = sizeof( _calibration_ct_rg_pos_calc ) / sizeof( _calibration_ct_rg_pos_calc[0] ), .width = sizeof( _calibration_ct_rg_pos_calc[0] )};
static LookupTable calibration_ct_bg_pos_calc = {.ptr = _calibration_ct_bg_pos_calc, .rows = 1, .cols = sizeof( _calibration_ct_bg_pos_calc ) / sizeof( _calibration_ct_bg_pos_calc[0] ), .width = sizeof( _calibration_ct_bg_pos_calc[0] )};
static LookupTable calibration_color_temp = {.ptr = _calibration_color_temp, .rows = 1, .cols = sizeof( _calibration_color_temp ) / sizeof( _calibration_color_temp[0] ), .width = sizeof( _calibration_color_temp[0] )};
static LookupTable calibration_ct65pos = {.ptr = _calibration_ct65pos, .rows = 1, .cols = sizeof( _calibration_ct65pos ) / sizeof( _calibration_ct65pos[0] ), .width = sizeof( _calibration_ct65pos[0] )};
static LookupTable calibration_ct40pos = {.ptr = _calibration_ct40pos, .rows = 1, .cols = sizeof( _calibration_ct40pos ) / sizeof( _calibration_ct40pos[0] ), .width = sizeof( _calibration_ct40pos[0] )};
static LookupTable calibration_ct30pos = {.ptr = _calibration_ct30pos, .rows = 1, .cols = sizeof( _calibration_ct30pos ) / sizeof( _calibration_ct30pos[0] ), .width = sizeof( _calibration_ct30pos[0] )};
static LookupTable calibration_evtolux_ev_lut = {.ptr = _calibration_evtolux_ev_lut, .rows = 1, .cols = sizeof( _calibration_evtolux_ev_lut ) / sizeof( _calibration_evtolux_ev_lut[0] ), .width = sizeof( _calibration_evtolux_ev_lut[0] )};
static LookupTable calibration_evtolux_lux_lut = {.ptr = _calibration_evtolux_lux_lut, .rows = 1, .cols = sizeof( _calibration_evtolux_lux_lut ) / sizeof( _calibration_evtolux_lux_lut[0] ), .width = sizeof( _calibration_evtolux_lux_lut[0] )};
static LookupTable calibration_black_level_r = {.ptr = _calibration_black_level_r, .cols = 2, .rows = sizeof( _calibration_black_level_r ) / sizeof( _calibration_black_level_r[0] ), .width = sizeof( _calibration_black_level_r[0][0] )};
static LookupTable calibration_black_level_gr = {.ptr = _calibration_black_level_gr, .cols = 2, .rows = sizeof( _calibration_black_level_gr ) / sizeof( _calibration_black_level_gr[0] ), .width = sizeof( _calibration_black_level_gr[0][0] )};
static LookupTable calibration_black_level_gb = {.ptr = _calibration_black_level_gb, .cols = 2, .rows = sizeof( _calibration_black_level_gb ) / sizeof( _calibration_black_level_gb[0] ), .width = sizeof( _calibration_black_level_gb[0][0] )};
static LookupTable calibration_black_level_b = {.ptr = _calibration_black_level_b, .cols = 2, .rows = sizeof( _calibration_black_level_b ) / sizeof( _calibration_black_level_b[0] ), .width = sizeof( _calibration_black_level_b[0][0] )};
static LookupTable calibration_static_wb = {.ptr = _calibration_static_wb, .rows = 1, .cols = sizeof( _calibration_static_wb ) / sizeof( _calibration_static_wb[0] ), .width = sizeof( _calibration_static_wb[0] )};
static LookupTable calibration_mt_absolute_ls_a_ccm = {.ptr = _calibration_mt_absolute_ls_a_ccm, .rows = 1, .cols = sizeof( _calibration_mt_absolute_ls_a_ccm ) / sizeof( _calibration_mt_absolute_ls_a_ccm[0] ), .width = sizeof( _calibration_mt_absolute_ls_a_ccm[0] )};
static LookupTable calibration_mt_absolute_ls_d40_ccm = {.ptr = _calibration_mt_absolute_ls_d40_ccm, .rows = 1, .cols = sizeof( _calibration_mt_absolute_ls_d40_ccm ) / sizeof( _calibration_mt_absolute_ls_d40_ccm[0] ), .width = sizeof( _calibration_mt_absolute_ls_d40_ccm[0] )};
static LookupTable calibration_mt_absolute_ls_d50_ccm = {.ptr = _calibration_mt_absolute_ls_d50_ccm, .rows = 1, .cols = sizeof( _calibration_mt_absolute_ls_d50_ccm ) / sizeof( _calibration_mt_absolute_ls_d50_ccm[0] ), .width = sizeof( _calibration_mt_absolute_ls_d50_ccm[0] )};
static LookupTable calibration_shading_ls_a_r = {.ptr = _calibration_shading_ls_a_r, .rows = 1, .cols = sizeof( _calibration_shading_ls_a_r ) / sizeof( _calibration_shading_ls_a_r[0] ), .width = sizeof( _calibration_shading_ls_a_r[0] )};
static LookupTable calibration_shading_ls_a_g = {.ptr = _calibration_shading_ls_a_g, .rows = 1, .cols = sizeof( _calibration_shading_ls_a_g ) / sizeof( _calibration_shading_ls_a_g[0] ), .width = sizeof( _calibration_shading_ls_a_g[0] )};
static LookupTable calibration_shading_ls_a_b = {.ptr = _calibration_shading_ls_a_b, .rows = 1, .cols = sizeof( _calibration_shading_ls_a_b ) / sizeof( _calibration_shading_ls_a_b[0] ), .width = sizeof( _calibration_shading_ls_a_b[0] )};
static LookupTable calibration_shading_ls_tl84_r = {.ptr = _calibration_shading_ls_tl84_r, .rows = 1, .cols = sizeof( _calibration_shading_ls_tl84_r ) / sizeof( _calibration_shading_ls_tl84_r[0] ), .width = sizeof( _calibration_shading_ls_tl84_r[0] )};
static LookupTable calibration_shading_ls_tl84_g = {.ptr = _calibration_shading_ls_tl84_g, .rows = 1, .cols = sizeof( _calibration_shading_ls_tl84_g ) / sizeof( _calibration_shading_ls_tl84_g[0] ), .width = sizeof( _calibration_shading_ls_tl84_g[0] )};
static LookupTable calibration_shading_ls_tl84_b = {.ptr = _calibration_shading_ls_tl84_b, .rows = 1, .cols = sizeof( _calibration_shading_ls_tl84_b ) / sizeof( _calibration_shading_ls_tl84_b[0] ), .width = sizeof( _calibration_shading_ls_tl84_b[0] )};
static LookupTable calibration_shading_ls_d65_r = {.ptr = _calibration_shading_ls_d65_r, .rows = 1, .cols = sizeof( _calibration_shading_ls_d65_r ) / sizeof( _calibration_shading_ls_d65_r[0] ), .width = sizeof( _calibration_shading_ls_d65_r[0] )};
static LookupTable calibration_shading_ls_d65_g = {.ptr = _calibration_shading_ls_d65_g, .rows = 1, .cols = sizeof( _calibration_shading_ls_d65_g ) / sizeof( _calibration_shading_ls_d65_g[0] ), .width = sizeof( _calibration_shading_ls_d65_g[0] )};
static LookupTable calibration_shading_ls_d65_b = {.ptr = _calibration_shading_ls_d65_b, .rows = 1, .cols = sizeof( _calibration_shading_ls_d65_b ) / sizeof( _calibration_shading_ls_d65_b[0] ), .width = sizeof( _calibration_shading_ls_d65_b[0] )};
static LookupTable calibration_awb_warming_ls_a = {.ptr = _calibration_awb_warming_ls_a, .rows = 1, .cols = sizeof( _calibration_awb_warming_ls_a ) / sizeof( _calibration_awb_warming_ls_a[0] ), .width = sizeof( _calibration_awb_warming_ls_a[0] )};
static LookupTable calibration_awb_warming_ls_d50 = {.ptr = _calibration_awb_warming_ls_d50, .rows = 1, .cols = sizeof( _calibration_awb_warming_ls_d50 ) / sizeof( _calibration_awb_warming_ls_d50[0] ), .width = sizeof( _calibration_awb_warming_ls_d50[0] )};
static LookupTable calibration_awb_warming_ls_d75 = {.ptr = _calibration_awb_warming_ls_d75, .rows = 1, .cols = sizeof( _calibration_awb_warming_ls_d75 ) / sizeof( _calibration_awb_warming_ls_d75[0] ), .width = sizeof( _calibration_awb_warming_ls_d75[0] )};
static LookupTable calibration_noise_profile = {.ptr = _calibration_noise_profile, .rows = 1, .cols = sizeof( _calibration_noise_profile ) / sizeof( _calibration_noise_profile[0] ), .width = sizeof( _calibration_noise_profile[0] )};
static LookupTable calibration_demosaic = {.ptr = _calibration_demosaic, .rows = 1, .cols = sizeof( _calibration_demosaic ) / sizeof( _calibration_demosaic[0] ), .width = sizeof( _calibration_demosaic[0] )};
static LookupTable calibration_wdr_np_lut = {.ptr = _calibration_wdr_np_lut, .rows = 1, .cols = sizeof( _calibration_wdr_np_lut ) / sizeof( _calibration_wdr_np_lut[0] ), .width = sizeof( _calibration_wdr_np_lut[0] )};
static LookupTable calibration_gamma = {.ptr = _calibration_gamma, .rows = 1, .cols = sizeof( _calibration_gamma ) / sizeof( _calibration_gamma[0] ), .width = sizeof( _calibration_gamma[0] )};
static LookupTable calibration_iridix_asymmetry = {.ptr = _calibration_iridix_asymmetry, .rows = 1, .cols = sizeof( _calibration_iridix_asymmetry ) / sizeof( _calibration_iridix_asymmetry[0] ), .width = sizeof( _calibration_iridix_asymmetry[0] )};
static LookupTable calibration_ca_filter_mem = {.ptr = _calibration_ca_filter_mem, .rows = 1, .cols = sizeof( _calibration_ca_filter_mem ) / sizeof( _calibration_ca_filter_mem[0] ), .width = sizeof( _calibration_ca_filter_mem[0] )};
static LookupTable calibration_ca_correction = {.ptr = _calibration_ca_correction, .rows = 1, .cols = sizeof( _calibration_ca_correction ) / sizeof( _calibration_ca_correction[0] ), .width = sizeof( _calibration_ca_correction[0] )};
static LookupTable calibration_ca_correction_mem = {.ptr = _calibration_ca_correction_mem, .cols = 10, .rows = sizeof( _calibration_ca_correction_mem ) / sizeof( _calibration_ca_correction_mem[0] ), .width = sizeof( _calibration_ca_correction_mem[0][0] )};
static LookupTable calibration_lut3d_mem = {.ptr = _calibration_lut3d_mem, .rows = 1, .cols = sizeof( _calibration_lut3d_mem ) / sizeof( _calibration_lut3d_mem[0] ), .width = sizeof( _calibration_lut3d_mem[0] )};

uint32_t get_calibrations_static_linear_imx219( ACameraCalibrations *c )
{
    uint32_t result = 0;
    if ( c != 0 ) {
        c->calibrations[CALIBRATION_SHADING_RADIAL_R] = &calibration_shading_radial_r;
        c->calibrations[CALIBRATION_SHADING_RADIAL_G] = &calibration_shading_radial_g;
        c->calibrations[CALIBRATION_SHADING_RADIAL_B] = &calibration_shading_radial_b;
        c->calibrations[CALIBRATION_DECOMPANDER0_MEM] = &calibration_decompander0_mem;
        c->calibrations[CALIBRATION_DECOMPANDER1_MEM] = &calibration_decompander1_mem;
        c->calibrations[CALIBRATION_LIGHT_SRC] = &calibration_light_src;
        c->calibrations[CALIBRATION_RG_POS] = &calibration_rg_pos;
        c->calibrations[CALIBRATION_BG_POS] = &calibration_bg_pos;
        c->calibrations[CALIBRATION_MESH_RGBG_WEIGHT] = &calibration_mesh_rgbg_weight;
        c->calibrations[CALIBRATION_MESH_LS_WEIGHT] = &calibration_mesh_ls_weight;
        c->calibrations[CALIBRATION_MESH_COLOR_TEMPERATURE] = &calibration_mesh_color_temperature;
        c->calibrations[CALIBRATION_WB_STRENGTH] = &calibration_wb_strength;
        c->calibrations[CALIBRATION_SKY_LUX_TH] = &calibration_sky_lux_th;
        c->calibrations[CALIBRATION_CT_RG_POS_CALC] = &calibration_ct_rg_pos_calc;
        c->calibrations[CALIBRATION_CT_BG_POS_CALC] = &calibration_ct_bg_pos_calc;
        c->calibrations[CALIBRATION_COLOR_TEMP] = &calibration_color_temp;
        c->calibrations[CALIBRATION_CT65POS] = &calibration_ct65pos;
        c->calibrations[CALIBRATION_CT40POS] = &calibration_ct40pos;
        c->calibrations[CALIBRATION_CT30POS] = &calibration_ct30pos;
        c->calibrations[CALIBRATION_EVTOLUX_EV_LUT] = &calibration_evtolux_ev_lut;
        c->calibrations[CALIBRATION_EVTOLUX_LUX_LUT] = &calibration_evtolux_lux_lut;
        c->calibrations[CALIBRATION_BLACK_LEVEL_R] = &calibration_black_level_r;
        c->calibrations[CALIBRATION_BLACK_LEVEL_GR] = &calibration_black_level_gr;
        c->calibrations[CALIBRATION_BLACK_LEVEL_GB] = &calibration_black_level_gb;
        c->calibrations[CALIBRATION_BLACK_LEVEL_B] = &calibration_black_level_b;
        c->calibrations[CALIBRATION_STATIC_WB] = &calibration_static_wb;
        c->calibrations[CALIBRATION_MT_ABSOLUTE_LS_A_CCM] = &calibration_mt_absolute_ls_a_ccm;
        c->calibrations[CALIBRATION_MT_ABSOLUTE_LS_D40_CCM] = &calibration_mt_absolute_ls_d40_ccm;
        c->calibrations[CALIBRATION_MT_ABSOLUTE_LS_D50_CCM] = &calibration_mt_absolute_ls_d50_ccm;
        c->calibrations[CALIBRATION_SHADING_LS_A_R] = &calibration_shading_ls_a_r;
        c->calibrations[CALIBRATION_SHADING_LS_A_G] = &calibration_shading_ls_a_g;
        c->calibrations[CALIBRATION_SHADING_LS_A_B] = &calibration_shading_ls_a_b;
        c->calibrations[CALIBRATION_SHADING_LS_TL84_R] = &calibration_shading_ls_tl84_r;
        c->calibrations[CALIBRATION_SHADING_LS_TL84_G] = &calibration_shading_ls_tl84_g;
        c->calibrations[CALIBRATION_SHADING_LS_TL84_B] = &calibration_shading_ls_tl84_b;
        c->calibrations[CALIBRATION_SHADING_LS_D65_R] = &calibration_shading_ls_d65_r;
        c->calibrations[CALIBRATION_SHADING_LS_D65_G] = &calibration_shading_ls_d65_g;
        c->calibrations[CALIBRATION_SHADING_LS_D65_B] = &calibration_shading_ls_d65_b;
        c->calibrations[CALIBRATION_AWB_WARMING_LS_A] = &calibration_awb_warming_ls_a;
        c->calibrations[CALIBRATION_AWB_WARMING_LS_D50] = &calibration_awb_warming_ls_d50;
        c->calibrations[CALIBRATION_AWB_WARMING_LS_D75] = &calibration_awb_warming_ls_d75;
        c->calibrations[CALIBRATION_NOISE_PROFILE] = &calibration_noise_profile;
        c->calibrations[CALIBRATION_DEMOSAIC] = &calibration_demosaic;
        c->calibrations[CALIBRATION_WDR_NP_LUT] = &calibration_wdr_np_lut;
        c->calibrations[CALIBRATION_GAMMA] = &calibration_gamma;
        c->calibrations[CALIBRATION_IRIDIX_ASYMMETRY] = &calibration_iridix_asymmetry;
        c->calibrations[CALIBRATION_AWB_SCENE_PRESETS] = &calibration_awb_scene_presets;
        c->calibrations[CALIBRATION_CA_FILTER_MEM] = &calibration_ca_filter_mem;
        c->calibrations[CALIBRATION_CA_CORRECTION] = &calibration_ca_correction;
        c->calibrations[CALIBRATION_CA_CORRECTION_MEM] = &calibration_ca_correction_mem;
        c->calibrations[CALIBRATION_LUT3D_MEM] = &calibration_lut3d_mem;
    } else {
        result = -1;
    }
    return result;
}
